package com.aipolice.service.face;

import com.aipolice.pojo.Face;
import com.aipolice.pojo.face.UserFaceInfoBean;
import com.aipolice.utils.ImageUtil;
import com.alibaba.fastjson.JSON;
import com.baidu.ai.aip.faceDatabase.FaceAdd;
import com.baidu.ai.aip.faceDatabase.FaceDatabaseService;
import com.baidu.ai.aip.faceDatabase.FaceDatabaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@Service
public class FaceSearchService {

    FaceDatabaseServiceImpl faceDatabaseService = new FaceDatabaseServiceImpl();

    public void add(String facepath,String user_id ,UserFaceInfoBean bean) throws Exception {
//  TODO 加入人脸库代码
//        String imgBase64 = ImageUtil.multipartFileToBASE64(faceImg);
        String userInfoJson = JSON.toJSONString(bean);
        faceDatabaseService.add(facepath,"testGroup",user_id,userInfoJson.toString());
        System.out.println(userInfoJson);
     }

     public void delete(String userid) throws Exception {
        faceDatabaseService.userDelete("@ALL",userid);
     }

     public String getUsers(String groupId){
        return faceDatabaseService.getUsers(groupId);
     }

}
